package com.mrjy.live.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mrjy.common.entity.WisDoc;
import com.mrjy.live.bo.IWisDocBo;



@Controller
@RequestMapping("live/wisdoc")
public class WisDocController{
	@Resource
	private IWisDocBo wisDocBo;
	
	/**
	 * 记录课程对应的文档
	 * @param session
	 * @param wisDoc
	 * @return
	 */
	@RequestMapping("/insert")
	@ResponseBody
	public Object insert(WisDoc wisDoc) {	
		String message="ok";
		try{
			wisDocBo.insertWisDoc(wisDoc);
		}catch(Exception e){
			e.printStackTrace();
			message="error";
		}
		return message;
	}
	
	
	/**
	 * 查询所属课程关联的文档
	 * @param session
	 * @return
	 */
	@RequestMapping("/query")
	@ResponseBody
	public Object query(WisDoc wisDoc) {		
		return wisDocBo.queryWisDocList(wisDoc);
	}
	
	
	/**
	 * 根据文档id删除文档
	 * @param session
	 * @return
	 */
	@RequestMapping("/deleteByDocId")
	@ResponseBody
	public Object deleteByDocId(WisDoc wisDoc) {
		String message="ok";
		try{	
		 wisDocBo.deleteWisDocByDocId(wisDoc.getDocCode());
		}catch(Exception e){
			e.printStackTrace();
			message="error";
		}
		return message;
	}
	
	/**
	 * 根据课程id删除文档
	 * @param session
	 * @return
	 */
	@RequestMapping("/deleteByLessonId")
	@ResponseBody
	public Object deleteByLessonId(WisDoc wisDoc) {
		String message="ok";
		try{	
		 wisDocBo.deleteWisDocByLessonId(wisDoc.getLessonId());
		}catch(Exception e){
			e.printStackTrace();
			message="error";
		}
		return message;
	}

	
	
	
	
	
}
